define('views/profile', ['text!/views/profile.html', 'components/left'], function(template, Left) {
  var MaxWidth = 160;
  var MaxHeight = 160;
  return {
    template: template,
    replace: true,
    data: function() {
      return {
        init: true,
        modify: {
          messageShow: false,
          qqShow: false,
          telphoneShow: false,
          userNameShow: false,
          userName: '',
          telphone: '',
          qq: ''
        }
      }
    },
    methods: {
      modifySubmit: modifySubmit
    },
    props: ['small', 'user', 'box'],
    created: function() {
      var vm = this;
      vm.leftData = vm.$parent.$data;
      vm.modify.userName = vm.user.userName;
      vm.modify.message = vm.user.message;
      vm.modify.telphone = vm.user.telphone;
      vm.modify.qq = vm.user.qq;
    },
    computed: {
    },
    components: {
      'app-left': Left
    }
  };
  function modifySubmit(type){
    var vm = this;
    var user = vm.user;
    var modify = vm.modify;
    if(modify[type] === '' || user[type] === modify[type]){
      modify[type+'Show'] = false;
      return;
    }
    var data = {
      uid: vm.user.uid
    };
    data[type] = modify[type];
    vm.$http.post('/user/update', data).then(function(res){
      res = res.data;
      if(res.code !== 0){
        if(res.code === 1006){
          alert('请正确填写。');
          return;
        }
        alert(res.message);
        return;
      }
      user[type] = modify[type];
      modify[type+'Show'] = false;
    });
  }
});